angular.module('starter', ['ui.router', 'ui.bootstrap', 'mgcrea.pullToRefresh', 'ngAnimate', 'starter.controllers', 'starter.services', 'xc.indexedDB'])

    .constant('loading', true)
    .constant('dbversion', 1)
    .constant('dbname', 'myapp')
    .constant('tablename', 'orders')
    .constant('tableIndex', 'order_sn')
    .config(function ($stateProvider, $urlRouterProvider, $indexedDBProvider, dbname, tablename, dbversion, tableIndex) {

        $indexedDBProvider
            .connection(dbname)
            .upgradeDatabase(dbversion, function (event, db, tx) {
                var objStore = db.createObjectStore(tablename, {keyPath: 'id', autoIncrement: true});
                objStore.createIndex(tableIndex, tableIndex, {unique: true});


                //objStore.createIndex('age_idx', 'age', {unique: false});
            });

        $urlRouterProvider.otherwise("/home");
        //
        // Now set up the states
        $stateProvider
            .state('home', {
                url: "/home",
                templateUrl: "templates/home.html",
                controller: 'HomeCtrl'
            })
            .state('view', {
                url: "/view/:id",
                templateUrl: "templates/view.html",
                controller: 'ViewCtrl'
            })
            .state('clear', {
                url: "/clear",
                templateUrl: "templates/message.html",
                controller: 'ClearCtrl'
            })


    })

